﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NeiBuZZ.aspx.cs" Inherits="Web.Pages.QuShui.DiXiaS.ZhangWuGL.NeiBuZZ" Theme="Default"%>

<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title> 
    <script src="../../../../JS/jquery.js" type="text/javascript"></script>
    <script src="../../../../JS/AddEditCancel.js"></script>
    <script type="text/javascript">


        //取消内部转账
        function qxnbzz() {
            if (confirm("确定取消内部转账吗？")) {
                hdCollection.Set("yhh", gvZhuanZhangLB.GetRowKey(gvZhuanZhangLB.GetFocusedRowIndex()));
                hdCollection.Set("ym", "11");
                ASPxCallback1.PerformCallback("qxnbzz");
            }

        }

        var r_out = -1, r_in = -1;
        var bh_out = 0, bh_in = 0;
        function qdClick() {
            if (txtYongHuM_out2.GetText() == "" && txtYingShouJE_out2.GetText() == "" && txtShiShouJE_out2.GetText() == "") {
                Validate1();
            }
            else {
                if (txtYongHuM_in2.GetText() == "" && txtYingShouJE_in2.GetText() == "" && txtShiShouJE_in2.GetText() == "") {
                    Validate2();
                }
                else {
                    queding();
                }
            }

        }

        function queding() {
            //alert(r_out+" "+r_in);
            if (r_out == "1" && r_in == "1") {
                if (txtZhuanZhangJE.GetText() == "") {
                    alert("请先输入转账金额！");
                }
                else if (parseFloat(txtZhuanZhangJE.GetText()) <= 0) {
                    alert("转账金额不能小于0！");
                }
                else {
                    if (parseFloat(txtZhuanZhangJE.GetText()) > parseFloat(txtShiShouJE_out2.GetText())) {
                        alert("转账金额不能大于实收金额");
                    }
                    else {
                        hdCollection.Set("yhh", bh_out);
                        hdCollection.Set("ym", bh_in);
                        ASPxCallback1.PerformCallback("qdzz");
                        btnQueDing.SetEnabled(false);
                    }
                }

            }
        }

        //转出费用信息验证
        function Validate1() {
            if (txtYongHuH_out2.GetText() == "" || txtShuiLiangNY_out2.GetText() == "") {
                alert("转出费用信息用户号、水量年月为空，请先输入！");
            }
            else {
                //debugger;
                //先验证是否有加价开账记录
                //转出费用信息
                var yhh_out = txtYongHuH_out2.GetText();
                var ym_out = txtShuiLiangNY_out2.GetText();
                hdCollection.Set("yhh", yhh_out);
                hdCollection.Set("ym", ym_out);
                ASPxCallback1.PerformCallback("setinfo_out");
            }
        }

        //转入费用信息验证
        function Validate2() {
            if (txtYongHuH_in2.GetText() == "" || txtShuiLiangNY_in2.GetText() == "") {
                alert("转入费用信息用户号、水量年月为空，请先输入！");
            }
            else {
                //转入费用信息
                var yhh_in = txtYongHuH_in2.GetText();
                var ym_in = txtShuiLiangNY_in2.GetText();
                hdCollection.Set("yhh", yhh_in);
                hdCollection.Set("ym", ym_in);
                ASPxCallback1.PerformCallback("setinfo_in");
            }
        }

        function ASPxCallback1Complete(rs) {
            var arr = rs.split('|');
            var type = arr[0];
            var state = arr[1];
            if (type == "setinfo_out") {
                var result = arr[2];
                if (result == "1") {
                    txtYongHuM_out2.SetText(arr[3]);
                    txtYingShouJE_out2.SetText(arr[4]);
                    txtShiShouJE_out2.SetText(arr[5]);
                    r_out = arr[6];
                    bh_out = arr[7];
                }
                else {
                    alert("您输入的转出费用信息没有找到加价开账记录");
                }
            }
            if (type == "setinfo_in") {
                var result = arr[2];
                if (result == "1") {
                    txtYongHuM_in2.SetText(arr[3]);
                    txtYingShouJE_in2.SetText(arr[4]);
                    txtShiShouJE_in2.SetText(arr[5]);
                    r_in = arr[6];
                    bh_in = arr[7];
                }
                else {
                    alert("您输入的转入费用信息没有找到加价开账记录");
                }
            }
            if (type == "qdzz") {
                if (arr[2] == "1") {
                    alert("确认转账成功");
                    txtShiShouJE_out2.SetText(parseFloat(txtShiShouJE_out2.GetText()) - parseFloat(txtZhuanZhangJE.GetText()));
                    txtShiShouJE_in2.SetText(parseFloat(txtShiShouJE_in2.GetText()) + parseFloat(txtZhuanZhangJE.GetText()));
                }
                else {
                    alert("转账失败");
                }
            }
            if (type == "qxnbzz") {
                if (arr[2] == "1") {
                    alert("取消内部转账成功");
                    gvZhuanZhangLB.PerformCallback();
                }
                else {
                    alert("取消失败");
                }
            }

        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="tabletitle1" align="center">
            内部转账
        </div>
        <div style="display: none;">
            <dx:ASPxHiddenField ID="hdCollection" ClientInstanceName="hdCollection" runat="server"></dx:ASPxHiddenField>
            <dx:ASPxCallback ID="ASPxCallback1" ClientInstanceName="ASPxCallback1" runat="server" OnCallback="ASPxCallback1_Callback" ClientSideEvents-CallbackComplete="function(s,e){ASPxCallback1Complete(e.result);}"></dx:ASPxCallback>
        </div>
        <div>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <dx:ASPxPageControl ID="ASPxPageControl1" runat="server" ActiveTabIndex="0" Width="98%" Height="535px" AutoPostBack="true">
                        <TabPages>
                            <dx:TabPage Text="内部转账">
                                <ContentCollection>
                                    <dx:ContentControl>
                                        <div style="width: 100%;">
                                            <div style="width: 48%; float: left;">
                                                <fieldset style="border: 1px solid #a3c0e8;">
                                                    <legend>转出费用信息</legend>
                                                    <table style="text-align: right; height: 150px; width: 100%;">
                                                        <tr>
                                                            <td style="width: 20%;"><span style="font-size: 12px;">用户号：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtYongHuH_out2" Width="60%" runat="server"  ClientEnabled="true" ClientInstanceName="txtYongHuH_out2">
                                                                    <ClientSideEvents KeyUp="function(s,e){inputNum(s);}" KeyPress="function(s,e){if (event.keyCode == 13) {$('#ASPxPageControl1_txtShuiLiangNY_out2_I').focus(); };}" />
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                            <td></td>
                                                        </tr>
                                                        <tr>
                                                            <td><span style="font-size: 12px;">水量年月：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtShuiLiangNY_out2" Width="60%" runat="server" ClientEnabled="true" ClientInstanceName="txtShuiLiangNY_out2">
                                                                    <ClientSideEvents KeyUp="function(s,e){inputNum(s);}" KeyPress="function(s,e){if (event.keyCode == 13) { Validate1(); };}"/>
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td><span style="font-size: 12px;">用户名：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtYongHuM_out2" Width="100%" runat="server" ClientEnabled="false" ClientInstanceName="txtYongHuM_out2">
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td><span style="font-size: 12px;">应收金额：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtYingShouJE_out2" Width="100%" runat="server" ClientEnabled="false" ClientInstanceName="txtYingShouJE_out2">
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td><span style="font-size: 12px;">实收金额：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtShiShouJE_out2" Width="100%" runat="server" ClientEnabled="false" ClientInstanceName="txtShiShouJE_out2">
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </fieldset>
                                            </div>
                                            <div style="width: 48%; float: right;">
                                                <fieldset style="border: 1px solid #a3c0e8;">
                                                    <legend>转入费用信息</legend>
                                                    <table style="text-align: right; height: 150px; width: 100%;">
                                                        <tr>
                                                            <td style="width: 20%;"><span style="font-size: 12px;">用户号：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtYongHuH_in2" Width="60%" runat="server"  ClientEnabled="true" ClientInstanceName="txtYongHuH_in2">
                                                                    <ClientSideEvents KeyUp="function(s,e){inputNum(s);}" KeyPress="function(s,e){if (event.keyCode == 13) { $('#ASPxPageControl1_txtShuiLiangNY_in2_I').focus();  };}"/>
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                            <td></td>
                                                        </tr>
                                                        <tr>
                                                            <td><span style="font-size: 12px;">水量年月：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtShuiLiangNY_in2" Width="60%" runat="server" ClientEnabled="true" ClientInstanceName="txtShuiLiangNY_in2">
                                                                    <ClientSideEvents KeyUp="function(s,e){inputNum(s);}" KeyPress="function(s,e){if (event.keyCode == 13) { Validate2(); };}"/>
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td><span style="font-size: 12px;">用户名：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtYongHuM_in2" Width="100%" runat="server" ClientEnabled="false" ClientInstanceName="txtYongHuM_in2">
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td><span style="font-size: 12px;">应收金额：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtYingShouJE_in2" Width="100%" runat="server" ClientEnabled="false" ClientInstanceName="txtYingShouJE_in2">
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td><span style="font-size: 12px;">实收金额：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtShiShouJE_in2" Width="100%" runat="server" ClientEnabled="false" ClientInstanceName="txtShiShouJE_in2">
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </fieldset>
                                            </div>
                                        </div>
                                        <div>
                                            <table style="height: 80px;">
                                                <tr>
                                                    <td colspan="3"></td>
                                                </tr>
                                                <tr>
                                                    <td><span style="font-size: 12px;">账务年月：</span></td>
                                                    <td>
                                                        <dx:ASPxTextBox runat="server" ID="txtZWNY" ClientEnabled="false"></dx:ASPxTextBox>
                                                       <%-- <dx:ASPxDateEdit  runat="server" ID="deZhuanZhangRQ" ClientInstanceName="deZhuanZhangRQ">
                                                             <CalendarProperties  ClearButtonText="清除" TodayButtonText="今天" ></CalendarProperties>
                                                        </dx:ASPxDateEdit>--%>
                                                    </td>
                                                    <td style="text-align:right;"><dx:ASPxLabel runat="server" ID="LABEL" Text="单位：元"></dx:ASPxLabel></td>
                                                </tr>
                                                <tr>
                                                    <td><span style="font-size: 12px;">转账金额：</span></td>
                                                    <td>
                                                        <dx:ASPxTextBox ID="txtZhuanZhangJE" Width="100%" runat="server"  ClientEnabled="true" ClientInstanceName="txtZhuanZhangJE">
                                                        </dx:ASPxTextBox>
                                                    </td>
                                                    <td>&nbsp;&nbsp;
                                                        <dx:ASPxButton ID="btnQueDing"  runat="server" Text="确定" ClientInstanceName="btnQueDing"  UseSubmitBehavior="false" AutoPostBack="false"><%--OnClick="btnQueDing_Click"--%>
                                                            <ClientSideEvents  Click="function(s,e){qdClick();}"/>
                                                        </dx:ASPxButton>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </dx:ContentControl>
                                </ContentCollection>
                            </dx:TabPage>
                            <dx:TabPage Text="内部转账列表">
                                <ContentCollection>
                                    <dx:ContentControl Height="800px">
                                        <div>
                                            <table>
                                                <tr>
                                                    <td style="width: 8%;"><span style="font-size: 12px;">用户号：</span></td>
                                                    <td>
                                                        <dx:ASPxTextBox ID="txtYongHuH1" Width="60%" runat="server" ClientEnabled="true" ClientInstanceName="txtYongHuH1">
                                                            <%--<ClientSideEvents KeyUp="function(s,e){inputNum(s);}" KeyPress="function(s,e){if (event.keyCode == 13) { $('#ASPxPageControl1_txtShuiLiangNY_in2_I').focus();  };}"/>--%>
                                                        </dx:ASPxTextBox>
                                                    </td>
                                                    <td style="width: 8%;"><span style="font-size: 12px;">目的用户号：</span></td>
                                                    <td>
                                                        <dx:ASPxTextBox ID="txtYongHuH2" Width="60%" runat="server" ClientEnabled="true" ClientInstanceName="txtYongHuH2">
                                                        </dx:ASPxTextBox>
                                                    </td>
                                                    <td style="width: 8%;"><span style="font-size: 12px;">账务年月：</span></td>
                                                    <td>
                                                        <dx:ASPxTextBox ID="txtZWYM2" Width="60%" runat="server" ClientEnabled="true" ClientInstanceName="txtZWYM2">
                                                        </dx:ASPxTextBox>
                                                    </td>
                                                    <td>
                                                        <dx:ASPxButton runat="server" ID="btnChaXunTab2" Text="查询" ClientInstanceName="btnChaXunTab2" OnClick="btnChaXunTab2_Click">
                                                            <%--<ClientSideEvents Click="function(s,e){if (event.keyCode == 13) {Seach(); };}"/>--%>
                                                        </dx:ASPxButton>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                        <div>
                                            <dx:ASPxGridView ID="gvZhuanZhangLB" ClientInstanceName="gvZhuanZhangLB" runat="server" AutoGenerateColumns="False" KeyFieldName="ID" 
                                                EnableCallBacks="false"   Width="100%"  OnCustomCallback="gvZhuanZhangLB_CustomCallback">
                                                <Columns>
                                                    <dx:GridViewDataTextColumn FieldName="YHH1" Caption="原用户号" Width="25%" >
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="YHH2" Caption="目的用户号" Width="25%">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="ZWYM" Caption="账务年月" Width="25%">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="N_JINE" Caption="转账金额(元)" Width="25%">
                                                    </dx:GridViewDataTextColumn>
                                                </Columns>
                                                <Settings VerticalScrollBarMode="Visible" VerticalScrollableHeight="400" HorizontalScrollBarMode="Auto" />
                                                <SettingsPager Mode="EndlessPaging" PageSize="100" AlwaysShowPager="true" FirstPageButton-Visible="true" />
                                                <Settings ShowFooter="True" />
                                                <SettingsBehavior AllowFocusedRow="True"  ColumnResizeMode="Control" />
                                                <SettingsBehavior ProcessFocusedRowChangedOnServer="true" />
                                                <%--<Settings VerticalScrollableHeight="200" VerticalScrollBarMode="Auto" HorizontalScrollBarMode="Auto" />
                                                <SettingsBehavior ProcessFocusedRowChangedOnServer="true" />--%>
                                            </dx:ASPxGridView>
                                        </div>
                                        <br />
                                       <%-- <div style="width: 100%;">
                                            <div style="width: 48%; float: left;">
                                                <fieldset style="border: 1px solid #a3c0e8;">
                                                    <legend>转出费用信息</legend>
                                                    <table style="text-align: right; height: 150px; width: 100%;">
                                                        <tr>
                                                            <td style="width: 20%;"><span style="font-size: 12px;">用户号：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtYongHuH_out" Width="60%" runat="server" Enabled="false">
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                            <td></td>
                                                        </tr>
                                                        <tr>
                                                            <td><span style="font-size: 12px;">用户名：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtYongHuM_out" Width="100%" runat="server" Enabled="false">
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td><span style="font-size: 12px;">水量年月：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtShuiLiangNY_out" Width="100%" runat="server" Enabled="false">
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td><span style="font-size: 12px;">应收金额：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtYingShouJE_out" Width="100%" runat="server" Enabled="false">
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td><span style="font-size: 12px;">实收金额：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtShiShouJE_out" Width="100%" runat="server" Enabled="false">
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </fieldset>
                                            </div>
                                            <div style="width: 48%; float: right;">
                                                <fieldset style="border: 1px solid #a3c0e8;">
                                                    <legend>转入费用信息</legend>
                                                    <table style="text-align: right; height: 150px; width: 100%;">
                                                        <tr>
                                                            <td style="width: 20%;"><span style="font-size: 12px;">用户号：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtYongHuH_in" Width="60%" runat="server" Enabled="false">
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                            <td></td>
                                                        </tr>
                                                        <tr>
                                                            <td><span style="font-size: 12px;">用户名：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtYongHuM_in" Width="100%" runat="server" Enabled="false">
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td><span style="font-size: 12px;">水量年月：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtShuiLiangNY_in" Width="100%" runat="server" Enabled="false">
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td><span style="font-size: 12px;">应收金额：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtYingShouJE_in" Width="100%" runat="server" Enabled="false">
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td><span style="font-size: 12px;">实收金额：</span></td>
                                                            <td>
                                                                <dx:ASPxTextBox ID="txtShiShouJE_in" Width="100%" runat="server" Enabled="false">
                                                                </dx:ASPxTextBox>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </fieldset>
                                            </div>
                                        </div>--%>

                                        <div>
                                            <table align="right">
                                                <tr>
                                                    <td>
                                                        <dx:ASPxButton ID="btnQuXiaoNBZZ" runat="server" Text="取消内部转账" AutoPostBack="false"  UseSubmitBehavior="false">
                                                            <ClientSideEvents  Click="function(s,e){qxnbzz();}"/>
                                                        </dx:ASPxButton>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </dx:ContentControl>
                                </ContentCollection>
                            </dx:TabPage>
                        </TabPages>
                    </dx:ASPxPageControl>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </form>
</body>
</html>

